package com.zmn.plat.services.impl.orderconfig.comment;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.zmn.common.dto.StatusDTO;
import com.zmn.plat.model.entity.orderconfig.comment.OrderComment;
import com.zmn.plat.model.entity.orderconfig.comment.OrderCommentQuery;
import com.zmn.plat.persistence.interfaces.orderconfig.comment.OrderCommentDAO;
import com.zmn.plat.services.interfaces.orderconfig.comment.OrderCommentService;

/**
 * @author tanbiao
 * @description
 * @since 2019/10/25 9:43
 * @modifier
 **/
@Service
public class OrderCommentServiceImpl implements OrderCommentService {
    @Autowired
    private OrderCommentDAO orderCommentDAO;

    @Override
    public OrderComment findByKey(int id) {
        return orderCommentDAO.findByKey(id);
    }

    @Override
    public List<OrderComment> findByKeys(List<Integer> ids) {
        return orderCommentDAO.findByKeys(ids);
    }

    @Override
    public Integer findMaxSort() {
        return orderCommentDAO.findMaxSort();
    }

    @Override
    public OrderComment findByComment(OrderCommentQuery query) {
        return orderCommentDAO.findByComment(query);
    }

    @Override
    public List<OrderComment> listByQuery(OrderCommentQuery query) {
        return orderCommentDAO.listByQuery(query);
    }

    @Override
    public List<OrderComment> listPageByQuery(OrderCommentQuery query) {
        return orderCommentDAO.listPageByQuery(query);
    }

    @Override
    public Integer countByQuery(OrderCommentQuery query) {
        return orderCommentDAO.countByQuery(query);
    }

    @Override
    public Integer updateByKey(OrderComment reason) {
        return orderCommentDAO.updateByKey(reason);
    }

    @Override
    public Integer updateSortKey(Integer id, Integer sort, String staffName) {
        OrderComment comment = new OrderComment();
        comment.setId(id);
        comment.setSort(sort);
        comment.setUpdateTime(new Date());
        comment.setUpdater(staffName);
        return orderCommentDAO.updateSortKey(comment);
    }

    @Override
    public Integer updateFirstLetterByKey(Integer id, String firstLetter, String staffName) {
        OrderComment comment = new OrderComment();
        comment.setId(id);
        comment.setFirstLetter(firstLetter);
        comment.setUpdateTime(new Date());
        comment.setUpdater(staffName);
        return orderCommentDAO.updateFirstLetterByKey(comment);
    }

    @Override
    public int updateStatusBatch(List<Integer> ids, Integer status, String staffName) {
        StatusDTO dto = new StatusDTO();
        dto.setIds(ids);
        dto.setStatus(status);
        dto.setUpdater(staffName);
        dto.setUpdateTime(new Date());
        return orderCommentDAO.updateStatusBatch(dto);
    }

    @Override
    public Integer insert(OrderComment comment) {
        return orderCommentDAO.insert(comment);
    }

    @Override
    public Integer deleteByKey(Integer id) {
        return orderCommentDAO.deleteByKey(id);
    }
}
